/* Layout */
import Index from "@/views/Index";
import Layout from "@/views/layout/Index";
import Reader from "@/views/layout/reader/Index";
import My from "@/views/My/Index";
import Library from "@/views/library/Index";
import Rankings from "@/views/rankings/Index";
import BookselfAndViewed from "@/views/My/bookselfAndViewed/Index";
import Feedback from "@/views/My/feedback/Index";

/**
 * 主路由
 */
export const appRouter = [
  {
    path: "/",
    redirect: {
      name: "index",
    },
    meta: {
      title: "Index",
    },
    component: Index,
    children: [
      {
        path: "/",
        redirect: {
          name: "home",
        },
        meta: {
          title: "Home",
          keepAlive: true,
        },
        component: Layout,
        children: [
          {
            path: "home",
            name: "home",
            meta: {
              title: "Home",
              keepAlive: true,
            },
            component: () =>
              import(/* webpackChunkName: 'Home' */ "@/views/homepage/Index"),
          },
          {
            path: "book-detail/:id",
            name: "bookDetail",
            meta: {
              title: "bookDetail",
              update: true,
              keepAlive: false,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Detail' */ "@/views/detail/book/Index"
              ),
          },
          {
            path: "library",
            redirect: "library/female/all/all",
            name: "library",
            meta: {
              title: "Library",
              keepAlive: true,
            },
            component: Library,
            // component: () =>
            //   import(/* webpackChunkName: 'Library' */ "@/views/library/Index"),
            children: [
              {
                path: "/library/:sex/:genre/:state",
                name: "libraryView",
                meta: {
                  title: "Library",
                  // update: true,
                  keepAlive: true,
                },
                component: () =>
                  import(
                    /* webpackChunkName: 'Library' */ "@/views/library/detail/Index"
                  ),
              },
            ],
          },
          {
            path: "rankings",
            redirect: "rankings/null",
            name: "rankings",
            meta: {
              title: "Rankings",
              keepAlive: true,
            },
            component: Rankings,
            // component: () =>
            //   import(/* webpackChunkName: 'Rankings' */ "@/views/rankings/Index"),
            children: [
              {
                path: "/rankings/:title",
                name: "rankingsView",
                meta: {
                  title: "Rankings",
                  keepAlive: false,
                },
                component: () =>
                  import(
                    /* webpackChunkName: 'Rankings' */ "@/views/rankings/detail/Index"
                  ),
              },
            ],
          },
          // {
          //   path: "download",
          //   redirect: "download/default",
          //   name: "download",
          //   meta: {
          //     title: "Download",
          //     keepAlive: true,
          //   },
          //   component: Download,
          //   children: [
          //     {
          //       path: "/download/:msg",
          //       name: "downloadApp",
          //       meta: {
          //         title: "DownloadApp",
          //         keepAlive: true,
          //       },
          //       component: () =>
          //         import(
          //           /* webpackChunkName: 'Download' */ "@/views/download/Index"
          //         ),
          //     },
          //   ],
          // },
          {
            path: "search/:keywords",
            name: "search",
            meta: {
              title: "Search",
              update: true,
              keepAlive: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Search' */ "@/views/detail/search/Index"
              ),
          },
          // {
          //   path: "/premium",
          //   name: "premium",
          //   meta: {
          //     title: "Premium",
          //     keepAlive: true,
          //     global: true,
          //   },
          //   component: () =>
          //     import(
          //       /* webpackChunkName: 'Home' */ "@/views/My/premium/Index"
          //     ),
          // },
          // {
          //   path: "/myAccount",
          //   name: "myAccount",
          //   meta: {
          //     title: "MyAccount",
          //     keepAlive: true,
          //     global: true,
          //   },
          //   component: () =>
          //     import(/* webpackChunkName: 'Home' */ "@/views/My/myAccount/Index"),
          // },
          {
            path: "my",
            redirect: {
              name: "bookself",
            },
            meta: {
              title: "My",
              keepAlive: true,
            },
            component: My,
            children: [
              {
                path: "/",
                redirect: {
                  name: "bookself",
                },
                meta: {
                  title: "Bookself",
                  keepAlive: true,
                },
                component: BookselfAndViewed,
                children: [
                  {
                    path: "bookself",
                    name: "bookself",
                    meta: {
                      title: "Bookself",
                      keepAlive: true,
                      update: true,
                    },
                    component: () =>
                      import(
                        /* webpackChunkName: 'My' */ "@/views/My/bookselfAndViewed/bookself/Index"
                      ),
                  },
                  {
                    path: "viewed",
                    name: "viewed",
                    meta: {
                      title: "Viewed",
                      keepAlive: true,
                      update: true,
                    },
                    component: () =>
                      import(
                        /* webpackChunkName: 'My' */ "@/views/My/bookselfAndViewed/viewed/Index"
                      ),
                  },
                ],
              },
              {
                path: "/feedback",
                name: "feedback",
                meta: {
                  title: "Feedback",
                  keepAlive: true,
                },
                component: Feedback,
                children: [
                  {
                    path: "send-feedback",
                    name: "sendFeedback",
                    meta: {
                      title: "Send Feedback",
                      keepAlive: true,
                    },
                    component: () =>
                      import(
                        /* webpackChunkName: 'Feedback' */ "@/views/My/feedback/sendFeedBack/Index"
                      ),
                  },
                  {
                    path: "my-feedback",
                    name: "myFeedback",
                    meta: {
                      title: "My Feedback",
                      keepAlive: true,
                      update: true,
                    },
                    component: () =>
                      import(
                        /* webpackChunkName: 'Feedback' */ "@/views/My/feedback/myFeedback/Index"
                      ),
                  },
                ],
              },
            ],
          },
        ],
      },
      {
        path: "/",
        redirect: {
          name: "reader",
        },
        meta: {
          title: "Reader",
          keepAlive: true,
        },
        component: Reader,
        children: [
          {
            path: "/reader/:id",
            name: "reader",
            meta: {
              title: "Reader",
              update: true,
              keepAlive: true,
              global: true,
            },
            component: () =>
              import(/* webpackChunkName: 'Reader' */ "@/views/Reader/Index"),
          },
          {
            path: "/bookEnd/:writingProcess/:bookId",
            name: "bookEnd",
            meta: {
              title: "BookEnd",
              keepAlive: true,
              update: true,
              global: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Reader' */ "@/views/Reader/bookEnd/Index"
              ),
          },
        ],
      },
    ],
  },
];

export const routes = [...appRouter];
